home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue58 / EasyWeb / WebCtrls.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-03-30  |  21.1 KB  |  780 lines

  1. { *****************************************************
  2.               TWebControls Components
  3.  
  4.   These Components allow the developer to use visual
  5.   components on WebBroker forms.
  6.  
  7.                   Paul Warren
  8.          HomeGrown Software Development
  9.        (c) 1997 Langley British Columbia.
  10.                 (604) 856-6523
  11.          e-mail:  hg_soft@uniserve.com
  12.     Home page: http://users.uniserve.com/~hg_soft
  13.   ***************************************************** }
  14.   
  15. unit WebCtrls;
  16.  
  17. interface
  18.  
  19. uses
  20.   Windows, SysUtils, Messages, Classes, Controls, Graphics, Charts, EnhCalnd,
  21.   XLabel, Grids, StdCtrls;
  22.  
  23. type
  24.   TWebControl = class(TComponent)
  25.   private
  26.     { Private declarations }
  27.     FWidth: integer;
  28.     FHeight: integer;
  29.     FContentType: string;
  30.     FControl: TControl;
  31.     function GetContentAsStream: TStream; virtual; abstract;
  32.     procedure SetOutput(Value: TBitmap); virtual;
  33.     function GetOutput: TBitmap; virtual;
  34.     procedure SetHeight(Value: integer);
  35.     procedure SetWidth(Value: integer);
  36.   protected
  37.     { Protected declarations }
  38.   public
  39.     { Public declarations }
  40.     property ContentAsStream: TStream read GetContentAsStream;
  41.     property ContentType: string read FContentType write FContentType;
  42.     property Width: integer read FWidth write SetWidth default 200;
  43.     property Height: integer read FHeight write SetHeight default 150;
  44.   published
  45.     { Published declarations }
  46.     property Output: TBitmap read GetOutput write SetOutput stored false;
  47.   end;
  48.  
  49.   TWebWinControl = class(TWebControl)
  50.   private
  51.     { Private declarations }
  52.     function GetContentAsStream: TStream; override;
  53.     function GetOutput: TBitmap; override;
  54.   protected
  55.     { Protected declarations }
  56.   public
  57.     { Public declarations }
  58.   published
  59.     { Published declarations }
  60.   end;
  61.  
  62.   TWebChart = class(TWebControl)
  63.   private
  64.     { Private declarations }
  65.     function GetContentAsStream: TStream; override;
  66.     procedure SetTitle(Value: TTitleStr);
  67.     procedure SetBorderWidth(Value: integer);
  68.     function GetTitle: TTitleStr;
  69.     function GetBorderWidth: integer;
  70.   protected
  71.     { Protected declarations }
  72.   public
  73.     { Public declarations }
  74.     procedure ClearData; virtual; abstract;
  75.   published
  76.     { Published declarations }
  77.     property Title: TTitleStr read GetTitle write SetTitle;
  78.     property BorderWidth: integer read GetBorderWidth write SetBorderWidth;
  79.     property ContentType;
  80.     property Width;
  81.     property Height;
  82.   end;
  83.  
  84.   TWebXYChart = class(TWebChart)
  85.   private
  86.     { Private declarations }
  87.     FOnNeedLinesX: TNeedLines;
  88.     FOnNeedLinesY: TNeedLines;
  89.     FOnScaling: TScaling;
  90.     FOnDrawScales: TDrawScales;
  91.     procedure SetXLabel(Value: TTitleStr);
  92.     procedure SetYLabel(Value: TTitleStr);
  93.     procedure SetGrid(Value: TGridType);
  94.     procedure SetChartType(Value: TChartType);
  95.     function GetChartType: TChartType;
  96.     function GetXLabel: TTitleStr;
  97.     function GetYLabel: TTitleStr;
  98.     function GetGrid: TGridType;
  99.     function GetOutput: TBitmap; override;
  100.   protected
  101.     { Protected declarations }
  102.     procedure DoNeedLinesX(Sender: TObject; var Value: Double; var AColor: TColor; var Finished: boolean);
  103.     procedure DoNeedLinesY(Sender: TObject; var Value: Double; var AColor: TColor; var Finished: boolean);
  104.     procedure DoScaling(Sender: TObject; var MinX, MaxX, MinY, MaxY: Double);
  105.     procedure DoDrawScales(Sender: TObject; Axis: TAxisType; Data: Double; var DataText: string);
  106.   public
  107.     { Public declarations }
  108.     constructor Create(AOwner: TComponent); override;
  109.     destructor Destroy; override;
  110.     procedure AddData(X, Y: Double);
  111.     procedure ClearData; override;
  112.   published
  113.     { Published declarations }
  114.     property ChartType: TChartType read GetChartType write SetChartType;
  115.     property XLabel: TTitleStr read GetXLabel write SetXLabel;
  116.     property YLabel: TTitleStr read GetYLabel write SetYLabel;
  117.     property Grid: TGridType read GetGrid write SetGrid;
  118.     property OnNeedLinesX: TNeedLines read FOnNeedLinesX write FOnNeedLinesX;
  119.     property OnNeedLinesY: TNeedLines read FOnNeedLinesY write FOnNeedLinesY;
  120.     property OnScaling: TScaling read FOnScaling write FOnScaling;
  121.     property OnDrawScales: TDrawScales read FOnDrawScales write FOnDrawScales;
  122.   end;
  123.  
  124.   TWebPieChart = class(TWebChart)
  125.   private
  126.     { Private declarations }
  127.     FOnDrawPie: TDrawPie;
  128.     FOnDrawLabel: TDrawLabel;
  129.     procedure SetXLabel(Value: TTitleStr);
  130.     procedure SetUseLabels(Value: boolean);
  131.     function GetUseLabels: boolean;
  132.     function GetXLabel: TTitleStr;
  133.     function GetOutput: TBitmap; override;
  134.   protected
  135.     { Protected declarations }
  136.     procedure DoDrawPie(Sender: TObject; var Color: TColor);
  137.     procedure DoDrawLabel(Sender: TObject; Data, DataSum: Double; var DataText: string);
  138.   public
  139.     { Public declarations }
  140.     constructor Create(AOwner: TComponent); override;
  141.     destructor Destroy; override;
  142.     procedure AddData(X: Double; Y: string);
  143.     procedure ClearData; override;
  144.   published
  145.     { Published declarations }
  146.     property XLabel: TTitleStr read GetXLabel write SetXLabel;
  147.     property UseLabels: boolean read GetUseLabels write SetUseLabels default true;
  148.     property OnDrawPie: TDrawPie read FOnDrawPie write FOnDrawPie;
  149.     property OnDrawLabel: TDrawLabel read FOnDrawLabel write FOnDrawLabel;
  150.   end;
  151.  
  152.   TRotatedLabel = class(TXLabel)
  153.   public
  154.     { Public declarations }
  155.     procedure PaintTo(DC: HDC; X, Y: Integer);
  156.   end;
  157.  
  158.   TWebRotatedLabel = class(TWebControl)
  159.   private
  160.     { Private declarations }
  161.     function GetContentAsStream: TStream; override;
  162.     function GetAngle: integer;
  163.     function GetRelief: boolean;
  164.     function GetColor: TColor;
  165.     function GetCaption: string;
  166.     function GetFont: TFont;
  167.     procedure SetAngle(Value: integer);
  168.     procedure SetRelief(Value: Boolean);
  169.     procedure SetColor(Value: TColor);
  170.     procedure SetCaption(Value: string);
  171.     procedure SetFont(Value: TFont);
  172.     function GetOutput: TBitmap; override;
  173.   protected
  174.     { Protected declarations }
  175.   public
  176.     { Public declarations }
  177.     constructor Create(AOwner: TComponent); override;
  178.     destructor Destroy; override;
  179.   published
  180.     { Published declarations }
  181.     property Angle: Integer read GetAngle write SetAngle;
  182.     property Relief: Boolean read GetRelief write SetRelief;
  183.     property Color: TColor read GetColor write SetColor;
  184.     property Caption: string read GetCaption write SetCaption;
  185.     property Font: TFont read GetFont write SetFont;
  186.     property ContentType;
  187.     property Width;
  188.     property Height;
  189.   end;
  190.  
  191.   TWebCalendar = class(TWebWinControl)
  192.   private
  193.     { Private declarations }
  194.     FOnNeedStrings: TNeedStrings;
  195.     function GetBlockWeekends: boolean;
  196.     function GetBlockedColor: TColor;
  197.     function GetFixedHeader: boolean;
  198.     function GetRangeColor: TColor;
  199.     function GetStartDate: TDateTime;
  200.     function GetEndDate: TDateTime;
  201.     function GetCalendarDate: TDateTime;
  202.     procedure SetBlockWeekends(Value: Boolean);
  203.     procedure SetBlockedColor(Value: TColor);
  204.     procedure SetCalendarDate(Value: TDateTime);
  205.     procedure SetFixedHeader(Value: Boolean);
  206.     procedure SetRangeColor(Value: TColor);
  207.     procedure SetStartDate(Value: TDateTime);
  208.     procedure SetEndDate(Value: TDateTime);
  209.   protected
  210.     { Protected declarations }
  211.     procedure DoNeedStrings(Sender: TObject; ACol, ARow: Integer; ADate: TDateTime; var Value: TStringList);
  212.   public
  213.     { Public declarations }
  214.     constructor Create(AOwner: TComponent); override;
  215.     destructor Destroy; override;
  216.   published
  217.     { Published declarations }
  218.     property BlockWeekends: Boolean read GetBlockWeekends write SetBlockWeekends default false;
  219.     property BlockedColor: TColor read GetBlockedColor write SetBlockedColor default clGray;
  220.     property CalendarDate: TDateTime read GetCalendarDate write SetCalendarDate stored false;
  221.     property FixedHeader: Boolean read GetFixedHeader write SetFixedHeader default True;
  222.     property RangeColor: TColor read GetRangeColor write SetRangeColor default clBlue;
  223.     property StartDate: TDateTime read GetStartDate write SetStartDate;
  224.     property EndDate: TDateTime read GetEndDate write SetEndDate;
  225.     property OnNeedStrings: TNeedStrings read FOnNeedStrings write FOnNeedStrings;
  226.     property Width;
  227.     property Height;
  228.     property ContentType;
  229.   end;
  230.  
  231. procedure Register;
  232.  
  233. implementation
  234.  
  235. uses JPeg, Forms;
  236.  
  237. { TWebControl }
  238. procedure TWebControl.SetHeight(Value: integer);
  239. begin
  240.   // make sure to change the control properties when
  241.   // changing the components properties
  242.   if Value <> FHeight then
  243.   begin
  244.     FHeight := Value;
  245.     FControl.Height := FHeight;
  246.   end;
  247. end;
  248.  
  249. procedure TWebControl.SetWidth(Value: integer);
  250. begin
  251.   // make sure to change the control properties when
  252.   // changing the components properties
  253.   if Value <> FWidth then
  254.   begin
  255.     FWidth := Value;
  256.     FControl.Width := FWidth;
  257.   end;
  258. end;
  259.  
  260. procedure TWebControl.SetOutput(Value: TBitmap);
  261. begin
  262.   // do nothing
  263. end;
  264.  
  265. function TWebControl.GetOutput: TBitmap;
  266. begin
  267.   Result := TBitmap.Create;
  268. end;
  269.  
  270. { TWebWinControl }
  271. function TWebWinControl.GetOutput: TBitmap;
  272. var
  273.   Dummy: TForm;
  274. begin
  275.   Result := inherited GetOutput;
  276.   try
  277.     Dummy := TForm.Create(nil);
  278.     try
  279.       FControl.Parent := Dummy;
  280.       Result.Width := FControl.Width;
  281.       Result.Height := FControl.Height;
  282.       Result.Canvas.Lock;
  283.       try
  284.         (FControl as TWinControl).PaintTo(Result.Canvas.Handle, 0, 0);
  285.         //Result.Assign((FControl as TRngSelCalendar).PaintTo(Result.Canvas.Handle, 0, 0));
  286.       finally
  287.         Result.Canvas.Unlock;
  288.       end;
  289.     finally
  290.       FControl.Parent := nil;
  291.       Dummy.Free;
  292.     end;
  293.   except
  294.     Result.Free;
  295.     raise;
  296.   end;
  297. end;
  298.  
  299. function TWebWinControl.GetContentAsStream: TStream;
  300. var
  301.   Dummy: TForm;
  302.   Jpg: TJpegImage;
  303. begin
  304.   Result := TMemoryStream.Create;
  305.   try
  306.     Dummy := TForm.Create(nil);
  307.     try
  308.       FControl.Parent := Dummy;
  309.       Jpg := TJpegImage.Create;
  310.       try
  311.         Jpg.Assign(Output);
  312.         Jpg.SaveToStream(Result);
  313.         Result.Position := 0;
  314.       finally
  315.         Jpg.Free;
  316.       end;
  317.     finally
  318.       FControl.Parent := nil;
  319.       Dummy.Free;
  320.     end;
  321.   except
  322.     Result.Free;
  323.     raise;
  324.   end;
  325. end;
  326.  
  327. { TWebChart }
  328. function TWebChart.GetContentAsStream: TStream;
  329. var
  330.   Jpg: TJpegImage;
  331.   S: TMemoryStream;
  332. begin
  333.   Jpg := TJpegImage.Create;
  334.   try
  335.     Jpg.Assign(Output);
  336.     S := TMemoryStream.Create;
  337.     Jpg.SaveToStream(S);
  338.     S.Position := 0;
  339.     Result := S;
  340.   finally
  341.     Jpg.Free;
  342.   end;
  343. end;
  344.  
  345. procedure TWebChart.SetTitle(Value: TTitleStr);
  346. begin
  347.   (FControl as ThgCustomChart).Title := Value;
  348. end;
  349.  
  350. procedure TWebChart.SetBorderWidth(Value: integer);
  351. begin
  352.   (FControl as ThgCustomChart).BorderWidth := Value;
  353. end;
  354.  
  355. function TWebChart.GetTitle: TTitleStr;
  356. begin
  357.   Result := (FControl as ThgCustomChart).Title;
  358. end;
  359.  
  360. function TWebChart.GetBorderWidth: integer;
  361. begin
  362.   Result := (FControl as ThgCustomChart).BorderWidth;
  363. end;
  364.  
  365. { TWebXYChart }
  366. constructor TWebXYChart.Create(AOwner: TComponent);
  367. begin
  368.   inherited Create(AOwner);
  369.   // set default properties
  370.   FContentType := 'image/jpeg';
  371.   FWidth := 200;
  372.   FHeight := 150;
  373.   // create underlying chart
  374.   FControl := TXYChart.Create(nil);
  375.   // set chart properties
  376.   FControl.Width := FWidth;
  377.   FControl.Height := FHeight;
  378.   (FControl as TXYChart).OnNeedLinesX := DoNeedLinesX;
  379.   (FControl as TXYChart).OnNeedLinesY := DoNeedLinesY;
  380.   (FControl as TXYChart).OnScaling := DoScaling;
  381.   (FControl as TXYChart).OnDrawScales := DoDrawScales;
  382. end;
  383.  
  384. destructor TWebXYChart.Destroy;
  385. begin
  386.   // free chart
  387.   FControl.Free;
  388.   inherited Destroy;
  389. end;
  390.  
  391. function TWebXYChart.GetOutput: TBitmap;
  392. var
  393.   i: integer;
  394. begin
  395.   if csDesigning in ComponentState then
  396.   begin
  397.     ClearData;
  398.     for i := 1 to 10 do AddData(i, i*2);
  399.   end;
  400.   Result := inherited GetOutput;
  401.   try
  402.     Result.Assign((FControl as ThgCustomChart).GetComponentImage);
  403.   except
  404.     Result.Free;
  405.     raise;
  406.   end;
  407. end;
  408.  
  409. procedure TWebXYChart.AddData(X, Y: Double);
  410. begin
  411.   // pass data through to chart
  412.   (FControl as TXYChart).AddData(X, Y);
  413. end;
  414.  
  415. procedure TWebXYChart.ClearData;
  416. begin
  417.   (FControl as TXYChart).ClearData;
  418. end;
  419.  
  420. procedure TWebXYChart.DoNeedLinesX(Sender: TObject; var Value: Double; var AColor: TColor; var Finished: boolean);
  421. begin
  422.   if Assigned(FOnNeedLinesX) then FOnNeedLinesX(Sender, Value, AColor, Finished);
  423. end;
  424.  
  425. procedure TWebXYChart.DoNeedLinesY(Sender: TObject; var Value: Double; var AColor: TColor; var Finished: boolean);
  426. begin
  427.   if Assigned(FOnNeedLinesY) then FOnNeedLinesY(Sender, Value, AColor, Finished);
  428. end;
  429.  
  430. procedure TWebXYChart.DoScaling(Sender: TObject; var MinX, MaxX, MinY, MaxY: Double);
  431. begin
  432.   if Assigned(FOnScaling) then FOnScaling(Sender, MinX, MaxX, MinY, MaxY);
  433. end;
  434.  
  435. procedure TWebXYChart.DoDrawScales(Sender: TObject; Axis: TAxisType; Data: Double; var DataText: string);
  436. begin
  437.   if Assigned(FOnDrawScales) then FOnDrawScales(Sender, Axis, Data, DataText);
  438. end;
  439.  
  440. procedure TWebXYChart.SetXLabel(Value: TTitleStr);
  441. begin
  442.   (FControl as TXYChart).XLabel := Value;
  443. end;
  444.  
  445. procedure TWebXYChart.SetYLabel(Value: TTitleStr);
  446. begin
  447.   (FControl as TXYChart).YLabel := Value;
  448. end;
  449.  
  450. procedure TWebXYChart.SetGrid(Value: TGridType);
  451. begin
  452.   (FControl as TXYChart).Grid := Value;
  453. end;
  454.  
  455. procedure TWebXYChart.SetChartType(Value: TChartType);
  456. begin
  457.   (FControl as TXYChart).ChartType := Value;
  458. end;
  459.  
  460. function TWebXYChart.GetChartType: TChartType;
  461. begin
  462.   Result := (FControl as TXYChart).ChartType;
  463. end;
  464.  
  465. function TWebXYChart.GetXLabel: TTitleStr;
  466. begin
  467.   Result := (FControl as TXYChart).XLabel;
  468. end;
  469.  
  470. function TWebXYChart.GetYLabel: TTitleStr;
  471. begin
  472.   Result := (FControl as TXYChart).YLabel;
  473. end;
  474.  
  475. function TWebXYChart.GetGrid: TGridType;
  476. begin
  477.   Result := (FControl as TXYChart).Grid;
  478. end;
  479.  
  480. { TWebPieChart }
  481. constructor TWebPieChart.Create(AOwner: TComponent);
  482. begin
  483.   inherited Create(AOwner);
  484.   // set default properties
  485.   FContentType := 'image/jpeg';
  486.   FWidth := 200;
  487.   FHeight := 150;
  488.   // create underlying chart
  489.   FControl := TPieChart.Create(nil);
  490.   // set chart properties
  491.   FControl.Width := FWidth;
  492.   FControl.Height := FHeight;
  493.   (FControl as TPieChart).OnDrawPie := DoDrawPie;
  494.   (FControl as TPieChart).OnDrawLabel := DoDrawLabel;
  495. end;
  496.  
  497. destructor TWebPieChart.Destroy;
  498. begin
  499.   // free chart
  500.   FControl.Free;
  501.   inherited Destroy;
  502. end;
  503.  
  504. function TWebPieChart.GetOutput: TBitmap;
  505. var
  506.   i: integer;
  507. begin
  508.   ClearData;
  509.   for i := 1 to 6 do
  510.     AddData(i*i, 'Data Point '+IntToStr(i));
  511.   Result := inherited GetOutput;
  512.   try
  513.     Result.Assign((FControl as ThgCustomChart).GetComponentImage);
  514.   except
  515.     Result.Free;
  516.     raise;
  517.   end;
  518. end;
  519.  
  520. procedure TWebPieChart.AddData(X: Double; Y: string);
  521. begin
  522.   // pass data through to chart
  523.   (FControl as TPieChart).AddData(X, Y);
  524. end;
  525.  
  526. procedure TWebPieChart.ClearData;
  527. begin
  528.   (FControl as TPieChart).ClearData;
  529. end;
  530.  
  531. procedure TWebPieChart.DoDrawPie(Sender: TObject; var Color: TColor);
  532. begin
  533.   if Assigned(FOnDrawPie) then FOnDrawPie(Sender, Color);
  534. end;
  535.  
  536. procedure TWebPieChart.DoDrawLabel(Sender: TObject; Data, DataSum: Double; var DataText: string);
  537. begin
  538.   if Assigned(FOnDrawLabel) then FOnDrawLabel(Sender, Data, DataSum, DataText);
  539. end;
  540.  
  541. procedure TWebPieChart.SetXLabel(Value: TTitleStr);
  542. begin
  543.   (FControl as ThgCustomChart).XLabel := Value;
  544. end;
  545.  
  546. procedure TWebPieChart.SetUseLabels(Value: boolean);
  547. begin
  548.   (FControl as TPieChart).UseLabels := Value;
  549. end;
  550.  
  551. function TWebPieChart.GetUseLabels: boolean;
  552. begin
  553.   Result := (FControl as TPieChart).UseLabels;
  554. end;
  555.  
  556. function TWebPieChart.GetXLabel: TTitleStr;
  557. begin
  558.   Result := (FControl as ThgCustomChart).XLabel;
  559. end;
  560.  
  561. { TRotatedLabel - PaintTo method }
  562. procedure TRotatedLabel.PaintTo(DC: HDC; X, Y: Integer);
  563. var
  564.   SaveIndex: Integer;
  565. begin
  566.   SaveIndex := SaveDC(DC);
  567.   MoveWindowOrg(DC, X, Y);
  568.   IntersectClipRect(DC, 0, 0, Width, Height);
  569.   Perform(WM_ERASEBKGND, DC, 0);
  570.   Perform(WM_PAINT, DC, 0);
  571.   RestoreDC(DC, SaveIndex);
  572. end;
  573.  
  574. { TWebChart }
  575. constructor TWebRotatedLabel.Create(AOwner: TComponent);
  576. begin
  577.   inherited Create(AOwner);
  578.   // set default properties
  579.   FContentType := 'image/jpeg';
  580.   FWidth := 200;
  581.   FHeight := 150;
  582.   // create underlying control
  583.   FControl := TRotatedLabel.Create(nil);
  584.   // set label properties
  585.   FControl.Width := FWidth;
  586.   FControl.Height := FHeight;
  587.   (FControl as TRotatedLabel).Caption := 'Rotating Label';
  588. end;
  589.  
  590. destructor TWebRotatedLabel.Destroy;
  591. begin
  592.   // free control
  593.   FControl.Free;
  594.   inherited Destroy;
  595. end;
  596.  
  597. function TWebRotatedLabel.GetOutput: TBitmap;
  598. begin
  599.   Result := inherited GetOutput;
  600.   try
  601.     Result.Width := FControl.Width;
  602.     Result.Height := FControl.Height;
  603.     Result.Canvas.Lock;
  604.     try
  605.       (FControl as TRotatedLabel).PaintTo(Result.Canvas.Handle, 0, 0);
  606.     finally
  607.       Result.Canvas.Unlock;
  608.     end;
  609.   except
  610.     Result.Free;
  611.     raise;
  612.   end;
  613. end;
  614.  
  615. function TWebRotatedLabel.GetContentAsStream: TStream;
  616. var
  617.   Jpg: TJpegImage;
  618.   S: TMemoryStream;
  619. begin
  620.   Jpg := TJpegImage.Create;
  621.   try
  622.     Jpg.Assign(Output);
  623.     S := TMemoryStream.Create;
  624.     Jpg.SaveToStream(S);
  625.     S.Position := 0;
  626.     Result := S;
  627.   finally
  628.     Jpg.Free;
  629.   end;
  630. end;
  631.  
  632. function TWebRotatedLabel.GetAngle: integer;
  633. begin
  634.   Result := (FControl as TRotatedLabel).Angle;
  635. end;
  636.  
  637. function TWebRotatedLabel.GetRelief: boolean;
  638. begin
  639.   Result := (FControl as TRotatedLabel).Relief;
  640. end;
  641.  
  642. function TWebRotatedLabel.GetColor: TColor;
  643. begin
  644.   Result := (FControl as TRotatedLabel).Color;
  645. end;
  646.  
  647. function TWebRotatedLabel.GetCaption: string;
  648. begin
  649.   Result := (FControl as TRotatedLabel).Caption;
  650. end;
  651.  
  652. function TWebRotatedLabel.GetFont: TFont;
  653. begin
  654.   Result := (FControl as TRotatedLabel).Font;
  655. end;
  656.  
  657. procedure TWebRotatedLabel.SetAngle(Value: integer);
  658. begin
  659.   (FControl as TRotatedLabel).Angle := Value;
  660. end;
  661.  
  662. procedure TWebRotatedLabel.SetRelief(Value: boolean);
  663. begin
  664.   (FControl as TRotatedLabel).Relief := Value;
  665. end;
  666.  
  667. procedure TWebRotatedLabel.SetColor(Value: TColor);
  668. begin
  669.   (FControl as TRotatedLabel).Color := Value;
  670. end;
  671.  
  672. procedure TWebRotatedLabel.SetCaption(Value: string);
  673. begin
  674.   (FControl as TRotatedLabel).Caption := Value;
  675. end;
  676.  
  677. procedure TWebRotatedLabel.SetFont(Value: TFont);
  678. begin
  679.   (FControl as TRotatedLabel).Font := Value;
  680. end;
  681.  
  682. { TWebCalendar }
  683. constructor TWebCalendar.Create(AOwner: TComponent);
  684. begin
  685.   inherited Create(AOwner);
  686.   // set default properties
  687.   FContentType := 'image/jpeg';
  688.   FWidth := 200;
  689.   FHeight := 150;
  690.   // create underlying calendar
  691.   FControl := TRngSelCalendar.Create(nil);
  692.   // set calendar properties
  693.   FControl.Width := FWidth;
  694.   FControl.Height := FHeight;
  695.   (FControl as TRngSelCalendar).OnNeedStrings := DoNeedStrings;
  696. end;
  697.  
  698. destructor TWebCalendar.Destroy;
  699. begin
  700.   // free calendar
  701.   FControl.Free;
  702.   inherited Destroy;
  703. end;
  704.  
  705. procedure TWebCalendar.DoNeedStrings(Sender: TObject; ACol,
  706.             ARow: Integer; ADate: TDateTime; var Value: TStringList);
  707. begin
  708.   if Assigned(FOnNeedStrings) then FOnNeedStrings(Sender, ACol, ARow, ADate, Value);
  709. end;
  710.  
  711. function TWebCalendar.GetBlockWeekends: boolean;
  712. begin
  713.   Result := (FControl as TRngSelCalendar).BlockWeekends;
  714. end;
  715.  
  716. function TWebCalendar.GetBlockedColor: TColor;
  717. begin
  718.   Result := (FControl as TRngSelCalendar).BlockedColor;
  719. end;
  720.  
  721. function TWebCalendar.GetFixedHeader: boolean;
  722. begin
  723.   Result := (FControl as TRngSelCalendar).FixedHeader;
  724. end;
  725.  
  726. function TWebCalendar.GetRangeColor: TColor;
  727. begin
  728.   Result := (FControl as TRngSelCalendar).RangeColor;
  729. end;
  730.  
  731. function TWebCalendar.GetCalendarDate: TDateTime;
  732. begin
  733.   Result := (FControl as TRngSelCalendar).CalendarDate;
  734. end;
  735.  
  736. function TWebCalendar.GetStartDate: TDateTime;
  737. begin
  738.   Result := (FControl as TRngSelCalendar).StartDate;
  739. end;
  740.  
  741. function TWebCalendar.GetEndDate: TDateTime;
  742. begin
  743.   Result := (FControl as TRngSelCalendar).EndDate;
  744. end;
  745.  
  746. procedure TWebCalendar.SetFixedHeader(Value: Boolean);
  747. begin
  748.   (FControl as TRngSelCalendar).FixedHeader := Value;
  749. end;
  750.  
  751. procedure TWebCalendar.SetBlockWeekends(Value: Boolean);
  752. begin
  753.   (FControl as TRngSelCalendar).BlockWeekends := Value;
  754. end;
  755.  
  756. procedure TWebCalendar.SetBlockedColor(Value: TColor);
  757. begin
  758.   (FControl as TRngSelCalendar).BlockedColor := Value;
  759. end;
  760.  
  761. procedure TWebCalendar.SetCalendarDate(Value: TDateTime);
  762. begin
  763.   (FControl as TRngSelCalendar).CalendarDate := Value;
  764. end;
  765.  
  766. procedure TWebCalendar.SetRangeColor(Value: TColor);
  767. begin
  768.   (FControl as TRngSelCalendar).RangeColor := Value;
  769. end;
  770.  
  771. procedure TWebCalendar.SetStartDate(Value: TDateTime);
  772. begin
  773.   (FControl as TRngSelCalendar).StartDate := Value;
  774. end;
  775.  
  776. procedure TWebCalendar.SetEndDate(Value: TDateTime);
  777. begin
  778.   (FControl as TRngSelCalendar).EndDate := Value;
  779. end;
  780.  
  781. procedure Register;
  782. begin
  783.   RegisterComponents('Internet', [TWebXYChart]);
  784.   RegisterComponents('Internet', [TWebPieChart]);
  785.   RegisterComponents('Internet', [TWebRotatedLabel]);
  786.   RegisterComponents('Internet', [TWebCalendar]);
  787. end;
  788.  
  789. end.
  790.